/**
 * Created by linxiaofen on 2017/5/21.
 */
'use strict';
app.component('myBlog',{
        templateUrl:'./view/template/blog.html',
        controller:function(httpService, $timeout){
            var ctrl = this;
            httpService.getBlog.query(function(data){
                ctrl.data = data;
            });
            carouselInit();
            angular.element(document).ready(function () {
                scrollBarsCtrl();
            });
            function carouselInit(){
                ctrl.myInterval = 2000;
                ctrl.noWrapSlides = false;
                ctrl.active = 0;
                var currIndex = 0;
                var slides = ctrl.slides = [{
                    image: 'images/blog/blog-1.jpg',
                    title: 'First Thumbnail label',
                    text:'Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.',
                    id: currIndex++
                },{
                    image: 'images/blog/blog-2.jpg',
                    title: 'First Thumbnail label',
                    text:'Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.',
                    id: currIndex++
                },{
                    image: 'images/blog/blog-3.jpg',
                    title: 'First Thumbnail label',
                    text:'Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.',
                    id: currIndex++
                }];
            }
            function scrollBarsCtrl(){
                if(window.matchMedia("(max-width: 800px)").matches){
                    $("#blog").mCustomScrollbar("destroy");
                }else{
                    $("#blog").mCustomScrollbar({
                        theme: "dark-2",
                        contentTouchScroll: true,
                        advanced: {
                            updateOnContentResize: true,
                            updateOnBrowserResize: true,
                            autoScrollOnFocus: false
                        }
                    });
                }
            }
        }


});
